import axios from '@/libs/axios1'
let jsonHeaders = {'content-type': 'application/json;charset=UTF-8'}
let exam = '/self-study/exam'
let exampaper = '/exampaper'
export const uploadPdf = (data) => {
  return axios({
    url: `/minio/upload/permanent?visibility=company&type=docs&bucket=docs`,
    method: 'post',
    data:data,
    // transformRequest:[ function(){
    //   return formdata
    // }],
    headers: {
      'Content-type':'multipart/form-data',
    },
    timeout:0
  })
}
export const getCorrectRateOfExaminationIds = (userId, data) => {
  return axios({
    url: `${exam}/userAnswer/getCorrectRateOfExaminationIds/${userId}`,
    method: 'post',
    data,
    headers: jsonHeaders
  })
}
// 查询点评
export const getRemark = (examinationId, userId) => {
  return axios({
    url:`${exam}/userAnswer/getExamPaperRemark/${examinationId}/${userId}`,
    method:'get',
    headers:jsonHeaders,
  })
}

// 删除点评
export const deleteRemark = (examinationId, userId) => {
  return axios({
    url:`${exam}/userAnswer/delExamPaperRemark/${examinationId}/${userId}`,
    method:'delete',
    headers:jsonHeaders,
  })
}

// 添加/修改点评
export const saveOrUpdateRemark = (examinationId, userId, remark) => {
  return axios({
    url:`${exam}/userAnswer/addExamPaperRemark`,
    method:'post',
    data: {
      examinationId,
      userId,
      remark
    },
    headers:jsonHeaders,
  })
}

export const getPaperIsUsed = paperId => {
  return axios({
    url:`${exam}/examination/pa/${paperId}`,
    method:'get',
    headers:jsonHeaders,
  })
}

export const updateExam = data => {
  return axios({
    url:`${exam}/examination/update`,
    method:'put',
    data,
    headers:jsonHeaders,
  })
}

//删除违规记录
export const delViolationRecord = id =>{
  return axios({
    url:`${exam}/examination/breakRule/del/${id}`,
    method:'delete',
    headers:jsonHeaders,
  })
}

// 获取自测违规记录考试
export const getViolationRecord = params =>{
  return axios({
    url:`${exam}/examination/breakRule/page`,
    method:'get',
    params,
    headers:jsonHeaders,
  })
}

//创建，修改考试
export const createExam = params =>{
  return axios({
    url:`${exam}/examination/saveOrUpdate`,
    method:'POST',
    headers:jsonHeaders,
    data:params
  })
}

//删除考试
export const delExam = params =>{
  return axios({
    url:`${exam}/examination/${params}`,
    method:'delete',
    headers:jsonHeaders,
  })
}

//查询考试列表
export const queryExam = params =>{
  return axios({
    url:`${exam}/examination/page`,
    method:'get',
    params:params,
    headers:jsonHeaders
  })
}
//查询考试详情
export const queryExamDetail = params =>{
  return axios({
    url:`${exam}/examination/${params}`,
    method:'get',
    headers:jsonHeaders
  })
}
//保存试卷
export const savePaper = examinationId => {
  return axios({
    url: `${exam}/userAnswer/savePaper/${examinationId}`,
    method: 'put',
    headers: jsonHeaders
  })
}

//获取考试排名
export const getExamRank = (examId,params) => {
  return axios({
    url: `${exam}/userAnswer/getRank/${examId}`,
    method: 'get',
    headers: jsonHeaders,
    params:params
  })
}

//查看考试成绩和排名
export const getRnak = (examid,params) => {
  return axios({
    url: `${exam}/userAnswer/getRank/${examid}`,
    method: 'get',
    params:params,
    headers: jsonHeaders
  })
}

//导出报告
export const exportReport= id => {
  return axios({
    url: `${exam}/examination/report/${id}`,
    method: 'get',
    headers: jsonHeaders
  })
}
//查询题目tag
export const getQuesTag = chaId => {
  return axios({
    url: `${exampaper}/examPaperLibs/ctfTags/${chaId}`,
    method: 'get',
    headers: jsonHeaders
  })
}
//查询题目file
export const getQuesFile = chaId => {
  return axios({
    url: `${exampaper}/examPaperLibs/ctfFiles/${chaId}`,
    method: 'get',
    headers: jsonHeaders
  })
}
//获取题目详情  暂用
export const getQuestionList = id => {
  return axios({
    url: `${exampaper}/testPaper/queryTestPaperInfo?paperId=${id}`,
    method: 'get',
    headers: jsonHeaders
  })
}

//获取试卷详情
export const getPaperDetail = (examinationId,userId) => {
  return axios({
    url:`${exam}/userAnswer/getExamPaperDetail/${examinationId}/${userId}`,
    method: 'get',
    params:{},
    headers: jsonHeaders
  })
}

/**
 * 获取学员考试提交情况
 * @param {*} params 
 * @returns 
 */
 export const getUserAnswerList = params => {
  return axios({
    url:`${exam}/userAnswer/getRankList/${params.examinationId}`,
    method: 'get',
    params,
    headers: jsonHeaders
  })
}

/**
 * 评分
 * @param {*} params 
 * @returns 
 */
export const marking = data => {
  return axios({
    url:`${exam}/userAnswer/teacherSubmitScore`,
    method: 'post',
    data,
    headers: jsonHeaders
  })
}

//考试中查询已提交用户考试成绩
export const getSubmitRank = (params, examinationId) => {
  return axios({
    url: `${exam}/userAnswer/getSubmitRank/${examinationId}`,
    method: 'get',
    params,
    headers: jsonHeaders
  })
}

//考试中查询所有用户考试成绩
export const getSubmitRankAll = (examinationId, params) => {
  return axios({
    url: `${exam}/userAnswer/getSubmitRankAll/${examinationId}`,
    method: 'get',
    params,
    headers: jsonHeaders
  })
}
//手动开始或结束考试
export const startOrFinish = (id, status) => {
  return axios({
    url: `${exam}/examination/startOrFinish/${id}?status=${status}`,
    method: 'post',
    headers: jsonHeaders
  })
}

// 个人考试结束交卷
export const submitPaper = (id,userid) => {
  return axios({
    url: `${exam}/examination/submit/${id}/${userid}`,
    method: 'post',
    headers: jsonHeaders
  })
}
// 列表统计考试试卷
export const getStatisticsExamPaper = (type) => {
  return axios({
    url: `${exam}/examination/statisticsExamPaper/${type}`,
    method: 'get',
    headers: jsonHeaders
  })
}